<template>
  <div>
    <div class="left-box">
      <div class="box-main box1">
        <div class="title">实时统计</div>
        <div class="box-tj">
          <ul>
            <img
              src="~assets/img/sy/ss-mark.png"
              alt="实时统计"
              class="dz-mark"
            />
            <li v-for="item in tongji">
              <div class="dz-num">{{ item.value }}</div>
              <span>{{ item.name }}</span>
            </li>
          </ul>
        </div>
        <p class="message-text">房屋结构</p>
        <div class="box-fw">
          <echart :options="option1" />
        </div>
      </div>
      <div class="box-main box2">
        <div class="title">各年安置房占比</div>
        <div class="box">
          <echart :options="option2" />
        </div>
      </div>
    </div>
    <div class="right-box">
      <div class="box-main box3">
        <div class="title">房屋安全等级占比</div>
        <div class="box">
          <echart :options="option3" />
        </div>
      </div>
      <div class="box-main box4">
        <div class="title">房屋概况</div>
        <div class="box">
          <echart :options="option4" />
        </div>
      </div>
      <div class="box-main box4">
        <div class="title">机构统计</div>
        <div class="box">
          <echart :options="option5" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Echart from "components/common/echart/Echart.vue";
import { echart16, echart17, echart18, echart19 } from "./option";
import { houseEnv } from "network/VRqj";
export default {
  components: { Echart },
  data() {
    return {
      option1: null,
      option2: null,
      option3: null,
      option4: null,
      option5: null,
      tongji: [
        {
          name: "道路硬化公里数",
          value: "439.58公里",
        },
        {
          name: "文化广场数",
          value: "16个",
        },
        {
          name: "路灯数量",
          value: "193个",
        },
        {
          name: "村级卫生室数量",
          value: "8个",
        },
        {
          name: "公共卫生间",
          value: "12个",
        },
        {
          name: "垃圾箱",
          value: "12个",
        },
        {
          name: "污水处理站",
          value: "1个",
        },
        {
          name: "垃圾处理站",
          value: "2个",
        },
      ],
    };
  },
  mounted() {
    this.option2 = echart17([
      { value: 2154, name: "2017年底完成" },
      { value: 3854, name: "2018年底完成" },
      { value: 3516, name: "2019年底完成" },
      { value: 3854, name: "2020年底完成" },
      { value: 2154, name: "闲置" },
    ]);
    this.option5 = echart19(
      ["卫生所", "养老院", "幼儿园"],
      [100, 200, 300, 400]
    );
  },
  created() {
    this.houseEnv(sessionStorage.getItem("cunId"));
  },
  methods: {
    async houseEnv(id) {
      let result = await houseEnv(id);
      let strX = [],
        strY = [];
      result.result.structureCount.forEach((element) => {
        strX.push(element.name);
        strY.push(element.value);
      });
      this.option1 = echart16(strX, strY);
      this.option3 = echart18(result.result.levelCount);
      this.option4 = echart17(result.result.liveCount);
    },
    refurbish(id) {
      this.houseEnv(id)
    }
  },
};
</script>

<style lang="scss" scoped>
.left-box {
  .box1 {
    .box-tj {
      width: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      ul {
        position: relative;
        width: 80%;
        padding: 0.3125rem 0;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-content: space-between;
        .dz-mark {
          width: 3.75rem;
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
        }
        li {
          width: 48%;
          height: 3.75rem;
          margin: 0.3125rem 0;
          color: #00f0ff;
          font-size: 0.875rem;
          background: rgba(0, 54, 255, 0.2);
          border: 0.0625rem solid #022ece;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
        }
        .dz-num {
          font-size: 1.25rem;
          font-family: shuzi;
        }
      }
    }
    .message-text {
      width: 100%;
      line-height: 1.875rem;
      color: #fff;
      text-indent: 2em;
      font-size: 1rem;
      margin: 0;
    }
    .box-fw {
      width: 100%;
      height: 6.25rem;
    }
  }
  .box2 {
    .box {
      width: 100%;
      height: 10rem;
    }
  }
}
.right-box {
  .box3 {
    .box {
      height: 12.5rem;
    }
  }
  .box4 {
    .box {
      height: 12.5rem;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-around;
      padding: 1.25rem;
    }
  }
}
</style>